<template >
  <div class="add_con_form tl" v-loading="loading">
    <el-dialog
      :close-on-click-modal="false"
      title="提现积分"
      :modal-append-to-body="false"
      :visible.sync="visible"
      :show="show"
      :before-close="closeDialog"
      @close="$emit('update:show',false)"
      class="tl size_13"
      width="900px"
    >
      <el-form :model="data" :rules="dataYZ" ref="data" class="mar_top" label-width="100px">
        <el-col :span="12">
          <el-form-item label="订单号" prop="oid" label-width="120px">
            <el-col :span="4">
              <el-input v-model="data.oid" :disabled="true" style="width:220px" clearable></el-input>
            </el-col>
          </el-form-item>

          <el-form-item label="实提金额" prop="money" label-width="120px">
            <el-col :span="4">
              <el-input v-model="data.real_money" :disabled="true" style="width:220px" clearable></el-input>
            </el-col>
          </el-form-item>
        </el-col>

        <el-col :span="12">
          <el-form-item label="申请时间" prop="created_time" label-width="120px">
            <el-col :span="4">
              <el-date-picker
                :disabled="true"
                :value="parseInt(data.created_time+'000')"
                type="datetime"
                placeholder="选择日期时间"
              ></el-date-picker>
            </el-col>
          </el-form-item>

          <el-form-item label="处理时间" prop="update_time" label-width="120px">
            <el-col :span="4">
              <el-date-picker
                :disabled="true"
                :value="parseInt(data.update_time+'000')"
                type="datetime"
                placeholder
              ></el-date-picker>
            </el-col>
          </el-form-item>
        </el-col>

        <el-form-item label="支付方式" label-width="120px">
          <el-col :span="4">
            <el-input
              class="inline-input"
              v-model="data.pay"
              :disabled="true"
              style="width:220px"
              clearable
            ></el-input>
          </el-col>
        </el-form-item>

        <el-form-item label="微信号" label-width="120px" v-show="pay_weixin">
          <el-col :span="4">
            <el-input
              class="inline-input"
              v-model="data.weixin"
              :disabled="true"
              style="width:220px"
              clearable
            ></el-input>
          </el-col>
        </el-form-item>

        <el-col :span="12">
          <el-form-item label="支付宝账号" label-width="120px" prop="alipay" v-show="pay_alipay">
            <el-col :span="4">
              <el-input v-model="data.alipay" :disabled="true" style="width:220px" clearable></el-input>
            </el-col>
          </el-form-item>

          <el-form-item label="银行卡号" label-width="120px" prop="alipay_realname" v-show="pay_bank">
            <el-col :span="4">
              <el-input v-model="data.card_number" :disabled="true" style="width:220px" clearable></el-input>
            </el-col>
          </el-form-item>

          <el-form-item label="开户省" prop="card_province" label-width="120px" v-show="pay_bank">
            <el-col :span="4">
              <el-input v-model="data.card_province" :disabled="true" style="width:220px" clearable></el-input>
            </el-col>
          </el-form-item>

          <el-form-item label="开户行" prop="card_bank" label-width="120px" v-show="pay_bank">
            <el-col :span="4">
              <el-input v-model="data.card_bank" :disabled="true" style="width:220px" clearable></el-input>
            </el-col>
          </el-form-item>
        </el-col>

        <el-col :span="12">
          <el-form-item
            label="支付宝真实姓名"
            label-width="120px"
            prop="alipay_realname"
            v-show="pay_alipay"
          >
            <el-col :span="4">
              <el-input v-model="data.alipay_name" :disabled="true" style="width:220px" clearable></el-input>
            </el-col>
          </el-form-item>

          <el-form-item label="开户名" prop="card_name" label-width="120px" v-show="pay_bank">
            <el-col :span="4">
              <el-input v-model="data.card_name" :disabled="true" style="width:220px" clearable></el-input>
            </el-col>
          </el-form-item>

          <el-form-item label="开户市" prop="card_city" label-width="120px" v-show="pay_bank">
            <el-col :span="4">
              <el-input v-model="data.card_city" :disabled="true" style="width:220px" clearable></el-input>
            </el-col>
          </el-form-item>

          <el-form-item label="开户网点" prop="card_web" label-width="120px" v-show="pay_bank">
            <el-col :span="4">
              <el-input v-model="data.card_web" :disabled="true" style="width:220px" clearable></el-input>
            </el-col>
          </el-form-item>
        </el-col>

        <el-form-item label="申请状态" label-width="120px">
          <el-col :span="12">
            <el-radio-group v-model="data.status" v-if="radio==0">
              <el-radio label="0">申请中</el-radio>
              <el-radio label="1">审核通过</el-radio>
              <el-radio label="2">申请驳回</el-radio>
            </el-radio-group>
            <el-radio-group v-model="data.status" disabled v-else>
              <el-radio label="0">申请中</el-radio>
              <el-radio label="1">审核通过</el-radio>
              <el-radio label="2">申请驳回</el-radio>
            </el-radio-group>
          </el-col>
        </el-form-item>

        <el-form-item label="管理员备注" prop="remark" label-width="120px">
          <el-col :span="12">
            <el-input placeholder="请输入备注" v-model="data.remark" style="width:480px" clearable></el-input>
          </el-col>
        </el-form-item>

        <el-form-item label="管理员" prop="admin_name" label-width="120px">
          <el-col :span="4">
            <el-input v-model="data.admin_name" :disabled="true" style="width:220px" clearable></el-input>
          </el-col>
        </el-form-item>

        <div class="mar_bottom_15">
          <span class="sizeColor size_13 sp_style"></span>
          <el-button
            :loading="$store.state.isLoading"
            size="medium"
            type="primary"
            @click.prevent="addUpdate('data')"
            :disabled="isDisable"
          >确定</el-button>
        </div>
      </el-form>
    </el-dialog>
  </div>
</template>


<style lang="less" scoped>
</style>

<script>
export default {
  data() {
    var checkTitle = (rule, value, callback) => {
      if (!value) {
        return callback(new Error("标题不能为空"));
      } else {
        callback();
      }
    };

    return {
      value: "",
      data: {
        id: "",
        adminId: "",
        status: "",
        remark: "",
        pay: ""
      },
      loading: false,
      radio: "",
      dataYZ: {
        title: [{ validator: checkTitle, trigger: "blur" }]
      },
      visible: this.show,
      isDisable: false,
      pay_weixin: false,
      pay_alipay: false,
      pay_bank: false
    };
  },
  props: {
    show: Boolean,
    editId: String,
    clickNum: Number
  },
  methods: {
    check_remark(val) {
      console.log(val);
      if (val == 2) {
        if (this.data.remark == "") {
          this.$fnc.alertError("请先填写管理员备注"); //失败弹出框
          this.getDetails(this.data.id);
          return false;
        }
      }
    },
    closeDialog() {
      //this.$refs['data'].resetFields();
      this.visible = false;
    },
    getDetails(id) {
      var data = {};
      data["id"] = id;
      this.$api.getUser.getWithdrawJfInfo(data).then(res => {
        this.data = res.data.result;
        this.radio = res.data.result.status;
        if (this.data.pay == "微信") {
          this.pay_weixin = true;
        } else {
          this.pay_weixin = false;
        }
        if (this.data.pay == "支付宝") {
          this.pay_alipay = true;
        } else {
          this.pay_alipay = false;
        }
        if (this.data.pay == "银行卡") {
          this.pay_bank = true;
        } else {
          this.pay_bank = false;
        }
      });
    },
    addUpdate(formName) {
      this.isDisable = true;
      setTimeout(() => {
        this.isDisable = false;
      }, 3000);
      this.$refs[formName].validate(valid => {
        if (valid) {
          var params = {};
          params["id"] = this.data.id;
          params["admin_id"] = this.data.adminId;
          params["status"] = this.data.status;
          params["remark"] = this.data.remark;
          this.$api.getUser.getWithdrawYeUpdate(params).then(res => {
            if (res.data.code == 200 && res.data.result != null) {
              this.$emit("parent", "这里刷新父页面");
              this.$fnc.alertSuccess({ text: "编辑成功" }); //成功弹出框
              this.visible = false;
            } else {
              this.$fnc.alertError(res.data.result); //失败弹出框
            }
          });
        }
      });
    }
  },
  watch: {
    show() {
      console.log(this.show);
      this.visible = this.show;
    },
    clickNum(id) {
      console.log("点击button次数", id);
      console.log("编辑ID=" + this.editId);
      this.getDetails(this.editId);
    }
  },
  mounted() {},
  created() {}
};
</script>
